//% color="#4169E1" iconWidth=50 iconHeight=40
namespace LiBatteryFuelGauge{

    //% block="Li-Battery Fuel Gauge initialization until successful I2C mode address 0x36" blockType="command" 
    export function init(parameter: any, block: any) {

        Generator.addImport("from DFRobot_MAX17043 import DFRobot_MAX17043");
        Generator.addCode(`batteryGauge = DFRobot_MAX17043()
while (batteryGauge.begin() != 0):
    print('gauge begin faild')
    time.sleep(2)
`);
   
    }

    //% block="get battery data [DATA]" blockType="reporter"
    //% DATA.shadow="dropdown"   DATA.options="DATA"
    export function getDate(parameter: any, block: any) { 
        let data = parameter.DATA.code;
        Generator.addCode( [`batteryGauge.${data}()`,Generator.ORDER_UNARY_POSTFIX]);
   
   } 




}